home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / scrnsave / scrmbler.frm < prev    next >
Text File  |  1995-05-08  |  7KB  |  188 lines

  1. VERSION 2.00
  2. Begin Form SCRMBLER 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Screen Scrambler Settings"
  5.    ClientHeight    =   3375
  6.    ClientLeft      =   2580
  7.    ClientTop       =   1065
  8.    ClientWidth     =   4095
  9.    Height          =   3780
  10.    Icon            =   SCRMBLER.FRX:0000
  11.    Left            =   2520
  12.    LinkTopic       =   "ScreenScramble"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3375
  16.    ScaleWidth      =   4095
  17.    Top             =   720
  18.    Width           =   4215
  19.    Begin CommandButton Cancel 
  20.       Cancel          =   -1  'True
  21.       Caption         =   "Cancel"
  22.       Height          =   375
  23.       Left            =   2160
  24.       TabIndex        =   7
  25.       Top             =   2880
  26.       Width           =   1695
  27.    End
  28.    Begin CommandButton OK 
  29.       Caption         =   "OK"
  30.       Default         =   -1  'True
  31.       Height          =   375
  32.       Left            =   240
  33.       TabIndex        =   6
  34.       Top             =   2880
  35.       Width           =   1695
  36.    End
  37.    Begin CommandButton Test 
  38.       Caption         =   "&Test"
  39.       Height          =   375
  40.       Left            =   2280
  41.       TabIndex        =   5
  42.       Top             =   2400
  43.       Width           =   1455
  44.    End
  45.    Begin CommandButton Setting 
  46.       Caption         =   "&Settings..."
  47.       Height          =   375
  48.       Left            =   360
  49.       TabIndex        =   4
  50.       Top             =   2400
  51.       Width           =   1455
  52.    End
  53.    Begin CommandButton Delete 
  54.       Caption         =   "&Delete"
  55.       Height          =   375
  56.       Left            =   1680
  57.       TabIndex        =   3
  58.       Top             =   1320
  59.       Width           =   735
  60.    End
  61.    Begin CommandButton Add 
  62.       Caption         =   "&Add "
  63.       Height          =   375
  64.       Left            =   1680
  65.       TabIndex        =   2
  66.       Top             =   720
  67.       Width           =   735
  68.    End
  69.    Begin FileListBox SCR_files 
  70.       Height          =   2175
  71.       Left            =   120
  72.       Pattern         =   "*.SCR"
  73.       TabIndex        =   1
  74.       Top             =   120
  75.       Width           =   1455
  76.    End
  77.    Begin ListBox SCRtoUSE 
  78.       Height          =   2175
  79.       Left            =   2520
  80.       TabIndex        =   0
  81.       Top             =   120
  82.       Width           =   1455
  83.    End
  84. End
  85. 'Get Windows Directory API call. Used to Get path for file list box.
  86. Declare Function GetWindowsDirectory Lib "Kernel" (ByVal lpBuffer As String, ByVal nSize As Integer) As Integer
  87. 'Windows API to see if program has terminated.
  88. Declare Function GetModuleUsage% Lib "Kernel" (ByVal hModule%)
  89.  
  90. Sub Add_Click ()
  91. If SCR_Files.FileName = "SCRMBLER.SCR" Or SCR_Files.FileName = "" Then Exit Sub'If selected screen saver is this one, or none, cancel procedure.
  92. If SCRtoUSE.ListCount > 0 Then
  93.     For Item% = 0 To SCRtoUSE.ListCount
  94.         'If Item is already on list, cancel procedure.
  95.         If SCRtoUSE.List(Item%) = SCR_Files.FileName Then Exit Sub
  96.     Next
  97. End If
  98. SCRtoUSE.AddItem SCR_Files.FileName' Add File from File list to Screen Saver List.
  99. End Sub
  100.  
  101. Sub Cancel_Click ()
  102. End 'Close Settings Window
  103. End Sub
  104.  
  105. Sub Delete_Click ()
  106. If SCRtoUSE.ListIndex = -1 Then Exit Sub 'If no items selected cancel procedure
  107. Li% = SCRtoUSE.ListIndex'Save list index
  108. SCRtoUSE.RemoveItem SCRtoUSE.ListIndex' Remove Saver from list
  109. SCRtoUSE.ListIndex = Li% - 1'Highlight Previous Item
  110. End Sub
  111.  
  112. Sub Form_Load ()
  113. On Error Resume Next'Enable Error Trapping
  114. If App.PrevInstance = True Then End' If already loaded, cancel this copy.
  115. If UCase$(Command$) = "/C" Then ' check for /C command line parameter to activate Settings window.
  116.     Left = Screen.Width / 2'Align Window (It looks better on SVGA using this)
  117.     Top = Screen.Height / 8'Align Window
  118.     SCR_Files.Path = Getwindowsdir()' Set file list box path to windows directory.
  119.     Open Getwindowsdir() + "SCRMBLER.DAT" For Input As #1'Open sequential data file
  120.     If Err <> 0 Then Close #1: Exit Sub'If file error, Don't create list
  121.     While Not EOF(1)'Loop until end of file
  122.         Input #1, Text$'Get text from file
  123.         SCRtoUSE.AddItem Text$'Add Text to list box.
  124.     Wend
  125.     Close #1'Close File
  126. End If
  127. If UCase$(Command$) = "/S" Then ' Check for /S to start screen Saver
  128.     Visible = False'Make sure Window is visible at no times
  129.     'for conveinince, savers are loaded into List box
  130.     Open Getwindowsdir() + "SCRMBLER.DAT" For Input As #1'Open sequential data file
  131.     If Err <> 0 Then Close #1: Exit Sub'If file error, Don't create list
  132.     While Not EOF(1)'Loop until end of file
  133.         Input #1, Text$'Get text from file
  134.         SCRtoUSE.AddItem Text$'Add Text to list box.
  135.     Wend
  136.     Close #1'Close File
  137.     Randomize'Initiate random number generator
  138.     SCRtoUSE.ListIndex = Int(Rnd * SCRtoUSE.ListCount)'Randomly Chose Saver
  139.     Test_Click'Show saver by seleting it in the list and clicking test button (done automaticly)
  140.     End'Exit Program
  141. End If
  142. End Sub
  143.  
  144. Function Getwindowsdir () As String 'Borrowed from the example setup program that came with VB.
  145.     temp$ = String$(145, 0)              ' Size Buffer
  146.     x = GetWindowsDirectory(temp$, 145)  ' Make API Call
  147.     temp$ = Left$(temp$, x)              ' Trim Buffer
  148.  
  149.     If Right$(temp$, 1) <> "\" Then      ' Add \ if necessary
  150.         Getwindowsdir$ = temp$ + "\"
  151.     Else
  152.         Getwindowsdir$ = temp$
  153.     End If
  154. End Function
  155.  
  156. Sub OK_Click ()
  157. Open Getwindowsdir() + "SCRMBLER.DAT" For Output As #1'Open List file
  158. If SCRtoUSE.ListCount > 0 Then
  159.     For Item% = 0 To SCRtoUSE.ListCount - 1
  160.         'Save List in sequential file
  161.         Print #1, SCRtoUSE.List(Item%)
  162.     Next
  163. End If
  164. Close #1'Close File
  165. End'Close Settings Window
  166. End Sub
  167.  
  168. Sub Setting_Click ()
  169. If SCRtoUSE.ListIndex = -1 Then Exit Sub'If No Item Selected, cancel procedure
  170. FileCopy Getwindowsdir() + SCRtoUSE.Text, "~LZLWLS.exe"'Copy file to an EXE file which can be used from VB, I just made up the name, It has no significance.
  171. x% = Shell("~LZLWLS.exe /c", 1)'Run Saver in settings window.
  172. While GetModuleUsage(x%) > 0'Check to see if program has terminated
  173.     DoEvents
  174. Wend
  175. Kill "~LZLWLS.exe"'Delete file
  176. End Sub
  177.  
  178. Sub Test_Click ()
  179. If SCRtoUSE.ListIndex = -1 Then Exit Sub'If No Item Selected, cancel procedure
  180. FileCopy Getwindowsdir() + SCRtoUSE.Text, "~LZLWLS.exe"'Copy file to an EXE file which can be used from VB, I just made up the name, It has no significance.
  181. x% = Shell("~LZLWLS.exe /s", 1)'Run Saver.
  182. While GetModuleUsage(x%) > 0'Check to see if program has terminated
  183.     DoEvents
  184. Wend
  185. Kill "~LZLWLS.exe"'Delete file
  186. End Sub
  187.  
  188.